{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=3177
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	k,cc,i:longint;
	a:array[0..100010] of longint;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
cc:=0;
while not eof do begin
	inc(cc);
	read(a[cc]);
end;
k:=a[cc-1];
dec(cc,2);
if k<0 then k:=cc-abs(k) mod cc else k:=k mod cc;
for i:=cc-k+1 to cc do
	write(a[i],' ');
for i:=1 to cc-k do
	write(a[i],' ');
end.